﻿@namespace SwashbucklerDiary.Pages
@inherits BackupsPageComponentBase

<MCard Elevation="0"
       Rounded="@("lg")">
    <MList>
        <MListItem OnClick="()=>ShowConfig=true">
            <MListItemIcon>
                <MIcon Class="list-item-icon">
                    mdi-cog-transfer-outline
                </MIcon>
            </MListItemIcon>

            <MListItemContent>
                <MListItemTitle>
                    @(I18n.T("Backups.Config.Title"))
                </MListItemTitle>
            </MListItemContent>

            <MListItemContent>
                <MListItemSubtitle Class="text-right">
                    @ConfiguredText
                </MListItemSubtitle>
            </MListItemContent>

            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-3"></MDivider>

        <MListItem OnClick="OpenUploadDialog">
            <MListItemIcon>
                <MIcon Class="list-item-icon">
                    mdi-cloud-arrow-up-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                <MListItemTitle>
                    @(I18n.T("Backups.Upload.Title"))
                </MListItemTitle>
                <MListItemSubtitle>
                    @(I18n.T("Backups.Backups.Subtitle"))
                </MListItemSubtitle>
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-3"></MDivider>

        <MListItem OnClick="OpenDownloadDialog">
            <MListItemIcon>
                <MIcon Class="list-item-icon">
                    mdi-cloud-arrow-down-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                <MListItemTitle>
                    @(I18n.T("Backups.Download.Title"))
                </MListItemTitle>
                <MListItemSubtitle>
                    @(I18n.T("Backups.Restore.Subtitle"))
                </MListItemSubtitle>
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>
    </MList>
</MCard>

<WebDavConfigDialog @bind-Value="ShowConfig"
                    WebDavConfigForm="configModel"
                    OnOK="SaveWebDavConfig">
</WebDavConfigDialog>

<MMDialog @bind-MyValue="ShowUpload"
          MaxWidth="420">
    <MCard Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Backups.Upload.Title"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="@(()=>ShowUpload=false)">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="pb-0">
            @(I18n.T("Backups.Upload.Content") + WebDavFolderName)
        </MCardText>
        <MCardActions>
            <MSpacer></MSpacer>
            <MButton Text="true"
                     OnClick="()=>ShowUpload=false">
                @(I18n.T("Share.Cancel"))
            </MButton>
            <MButton Text="true"
                     Color="primary"
                     OnClick="Upload">
                @(I18n.T("Share.OK"))
            </MButton>
        </MCardActions>
    </MCard>
</MMDialog>

<MMDialog @bind-MyValue="ShowDownload"
          MaxWidth="420"
          Scrollable="true">
    <MCard Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Backups.Download.Title"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="()=>ShowDownload=false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="scroll-show pb-0 mb-5"
                   Style="max-height:300px;">
            @foreach (var item in FileList)
            {
                <MListItem Class="px-0"
                           OnClick="()=>Download(item)">
                    <MListItemIcon>
                        <MIcon Class="list-item-icon">
                            mdi-file-outline
                        </MIcon>
                    </MListItemIcon>
                    <MListItemContent>
                        @item
                    </MListItemContent>
                </MListItem>
            }
        </MCardText>
    </MCard>
</MMDialog>

